package com.bwf.dt;

/**
 * @Version v1.0
 * @Description: TODO
 * @Author ZHANZHONGXIN
 * @Date 2022/5/10 15:29
 * @Copyright 博为峰
 */
public class Test02 {
    public static void main(String[] args) {
        Programmer programmer = new Programmer();
//        m1(programmer);
//        m2(programmer);
        Manager manager = new Manager();
//        m2(manager);

        m3(programmer);
        m3(manager);
    }

    //解耦(高内聚，低耦合)
    //Employee employee = programmer
    //Employee employee = manager
    //ClassCastException 类型转换异常
    //instanceof 引用类型判断
    public static void m3(Employee employee) {
        employee.work();
        if(employee instanceof Programmer){
            Programmer programmer = (Programmer) employee;
            programmer.coding();
        }
        if(employee instanceof Manager){
            Manager manager = (Manager) employee;
            manager.plan();
        }
    }

    public static void m1(Programmer programmer) {
        programmer.work();
        programmer.coding();
    }

    public static void m2(Manager manager) {
        manager.work();
        manager.plan();
    }
}
